<template>
    <div class="menber-center">
        <div class="items">
            <ul class="clearfix">
                <li class="fl" @click="datys.dateType=1,membersNow()" :class="{'active':datys.dateType==1}">今天</li>
                <li class="fl" @click="datys.dateType=2,membersNow()" :class="{'active':datys.dateType==2}">本周</li>
                <li class="fl" @click="datys.dateType=3,membersNow()" :class="{'active':datys.dateType==3}">本月</li>
                <li class="fl" @click="datys.dateType=4,membersNow()" :class="{'active':datys.dateType==4}">全部</li>
            </ul>
        </div>
        <div class="listme">
            <div class="tab">
                <ul class="clearfix">
                    <li class="fl">姓名</li>
                    <li class="fl">手机号</li>
                    <li class="fl">奖金金额</li>
                    <li class="fl">获得日期</li>
                </ul>
            </div>
            <div class="tabs">
                <ul class="clearfix" v-for="list in lists">
                    <!-- <li class="fl">{{list.name.replace(/^(.).+(.)$/g,'$1**')}}</li> -->
                    <li class="fl">{{list.name.replace(/.(?=.)/g, '*')}}</li>
                    <!-- <li class="fl">{{list.name.replace(/(\d{3})\d{4}$/,'**'))}}</li> -->
                    <li class="fl">{{list.mobile.replace(/^(\d{3})\d{4}(\d{4})$/,'$1****$2')}}</li>
                    <li class="fl">{{list.turnover}}</li>
                    <li class="fl">{{list.strOt.substring(0, 10)}}</li>
                </ul>
            </div>
        </div>
         <div class="tips" v-if="lists.length==0">
            <img src="../../assets/imgs/member/tips-3.png" alt="">
            <p>您暂无奖金记录～</p>
        </div>
        <div class="foots">
            <div class="content">
                <div class="money clearfix">
                    <span class="fl">可提现奖励金：</span>
                    <span class="fl">{{infor.fixedAssets}}</span>
                    <span class="fl">元</span>
                    <img src="../../assets/imgs/member/yw.png" alt="" class="fr">
                    <span class="rule fr">奖励金规则</span>
                </div>
                <div class="tab clearfix">
                    <p class="goto fl" @click="isCshow=true">转到余额</p>
                    <p class="cash fl" @click="direct('applyCash')">申请提现</p>
                </div>
            </div>
        </div>
        <!-- 弹出层 -->
        <div class="mask" v-if="isCshow==true">
            <div class="hyfl">
                <div class="words">
                    <p>奖励金：{{infor.fixedAssets}}元</p>
                    <input v-model="params.balance" type="text" placeholder="请输入金额" maxlength="9" onkeyup="this.value= this.value.match(/\d+(\.\d{0,1})?/) ? this.value.match(/\d+(\.\d{0,1})?/)[0] : ''" onblur='this.value=this.value.replace(/^[0]+[0-9]*$/gi,"")'>
                </div>
                <div class="confirm">
                    <p @click="isCshow=false">取消</p>
                    <p @click="gotoNow()">确认</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import http from "@/assets/js/axios";
import { domain } from '@/assets/js/config'
import $ from 'jquery'
import { Toast } from 'mint-ui';
export default {
    data() {
        return {
            isAshow: false,
            isBshow: false,
            isCshow: false,
            userToken: '',
            infor: '',
            lists: [],
            datys: {
                dateType: 1
            },
            params: {
                balance: ''
            }
        }
    },
    components: {

    },
    mounted() {
        let userToken = localStorage.getItem("token") || ''
        this.userToken = userToken
        if (!this.userToken) {
            this.$router.push('/login')
        }
        this.membersNow();
        this.inforNow();
    },
    methods: {
        direct: function (val) {
            this.$router.push({ path: '/' + val });
        },
        membersNow: async function () {
            const res = await http.post('xshk/f/user/recommendList?token=' + this.userToken, this.datys)
            // console.log(res);
            if (res.data.code == 0) {
                this.lists = res.data.data.TJ_WEEK
            }
        },
        gotoNow: async function () {
            const res = await http.post('xshk/f/assets/fixedAmountToBalance?token=' + this.userToken, this.params)
            // console.log(res);
            var that = this
            if (res.data.code == 0) {
                Toast({ message: res.data.message, duration: 1000 });
                setTimeout(function () {
                    that.$router.push('/center')
                }, 1000);

                // window.location.reload()
            } else {
                Toast({ message: res.data.message, duration: 1000 });
            }
        },
        inforNow: async function () {
            const res = await http.post('xshk/f/assets/query?token=' + this.userToken)
            // console.log(res);
            if (res.data.code == 0) {
                this.infor = res.data.data
            }
        },
    }
}
</script>

<style lang="stylus" scoped>
.menber-center {
    height: 100%;

    .items {
        ul {
            li {
                margin: 10px 9px;
                width: 75px;
                height: 32px;
                line-height: 32px;
                text-align: center;
                border: 1px solid #999;
                font-size: 16px;
                font-family: PingFangSC-Regular;
                font-weight: 400;
                color: rgba(153, 153, 153, 1);
                border-radius: 5px;
            }

            .active {
                background-color: #aad114;
                color: #fff;
                border: 1px solid #aad114;
            }
        }
    }

    .listme {
        div.tab {
            padding: 10px 15px;
            border-bottom: 1px solid rgba(240, 240, 240, 1);

            ul {
                text-align: center;

                li {
                    width: 25%;
                    font-size: 14px;
                    font-family: PingFangSC-Regular;
                    font-weight: 400;
                    color: rgba(153, 153, 153, 1);
                }
            }
        }

        div.tabs {
            padding: 10px 15px;

            ul {
                text-align: center;
                margin: 10px 0;

                li {
                    width: 25%;
                    font-size: 12px;
                    font-family: PingFangSC-Regular;
                    font-weight: 400;
                    color: rgba(51, 51, 51, 1);
                }
            }
        }
    }

    .tips {
        margin-top: 50px;
        width: 100%;
        text-align: center;
        font-size: 16px;
        font-family: PingFangSC-Regular;
        font-weight: 400;
        color: rgba(221, 221, 221, 1);

        img {
            width: 150px;
            height: 150px;
        }
    }

    .foots {
        width: 100%;
        z-index: 99;
        overflow: hidden;

        .content {
            position: fixed;
            left: 0;
            bottom: 0;
            right: 0;
            overflow: hidden;

            .money {
                padding: 0 15px;
                width: 100%;
                border-top: 1px solid #999;
                height: 45px;
                line-height: 45px;
                font-family: PingFangSC-Regular;
                font-weight: 400;
                color: rgba(51, 51, 51, 1);
                font-size: 16px;

                span:nth-child(2) {
                    color: #FF8400;
                }

                span.rule {
                    font-size: 14px;
                    font-family: PingFangSC-Regular;
                    font-weight: 400;
                    color: rgba(0, 96, 253, 1);
                }

                img {
                    height: 100%;
                }
            }

            .tab {
                width: 100%;
                height: 50px;
                line-height: 50px;
                background-color: #fff;
                font-size: 16px;
                font-family: PingFangSC-Regular;
                font-weight: 400;
                color: rgba(51, 51, 51, 1);
                text-align: center;
                border-top: 1px solid #999;

                .goto {
                    width: 50%;
                }

                .cash {
                    width: 50%;
                    background: rgba(154, 221, 8, 1);
                    color: rgba(255, 255, 255, 1);
                }
            }
        }
    }

    .mask {
        position: fixed;
        box-sizing: border-box;
        left: 0px;
        top: 0px;
        right: 0px;
        bottom: 0px;
        background-color: rgba(0, 0, 0, 0.85);
        z-index: 999;

        .hyfl {
            margin: 0 auto;
            margin-top: 100px;
            width: 300px;
            height: 200px;
            background-color: #fff;
            position: relative;

            .words {
                font-size: 16px;
                text-align: center;
                padding: 20px 0;
            }

            input {
                margin-top: 30px;
                text-align: center;
                height: 20px;
                font-size: 16px;
                border-bottom: 1px solid #999;
            }

            .confirm {
                position: absolute;
                bottom: 0px;
                text-align: center;
                width: 100%;
                height: 50px;
                line-height: 50px;
                border-top: 1px solid #f0f0f0;

                p {
                    float: left;
                    width: 50%;
                    font-size: 16px;
                    font-family: Adobe Heiti Std R;
                    font-weight: normal;
                    color: rgba(153, 153, 153, 1);
                }

                p:nth-child(2) {
                    border-left: 1px solid #f0f0f0;
                    color: #A6D400;
                }
            }
        }
    }
}
</style>
